package com.huohua.jobschduler.service.impl;
import com.huohua.jobschduler.JobProcess.DependencyResolver;
import com.huohua.jobschduler.model.po.JobNode;
import com.huohua.jobschduler.model.po.Result;
import com.huohua.jobschduler.service.JobSchdulerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;



@Slf4j
@Service
public class JobSchdulerServiceImpl implements JobSchdulerService {
    @Resource
    private DependencyResolver dependencyResolver;

    @Override
    public Result jobSchdulerProcess(String jobId) {
        long startTime = System.currentTimeMillis();
        log.info("任务调度开始");
        JobNode errorPaths = dependencyResolver.findErrorPaths(jobId);

        long endTime = System.currentTimeMillis();
        long duration = endTime - startTime;  // 计算执行时间（毫秒）

        log.info("任务调度结束, 返回结果: {}，耗时: {} 毫秒", errorPaths, duration);
        return new  Result(errorPaths,duration);
    }
}
